home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / vla / waves.lzh / waves.asm < prev    next >
Assembly Source File  |  1993-06-14  |  7KB  |  383 lines

  1.     Dosseg
  2.     .Model Small
  3.     .Stack 200h
  4.     .Code
  5.     .386
  6.     Assume CS:@CODE, DS:@CODE
  7.     Ideal
  8. ────────────────────────────────────────────────────────────────────────────
  9. Include "Vga16.inc"
  10. Save1       db  "plane1.dat",0
  11. Save2       db  "plane2.dat",0
  12.  
  13. Palette     db  24, 19, 17
  14.             db  34, 27, 26
  15.             db  17, 13, 13
  16.             db  48, 38, 36
  17.  
  18.             db  24, 19, 47
  19.             db  34, 27, 56
  20.             db  17, 13, 43
  21.             db  48, 38, 63
  22.  
  23.             db  34, 29, 27
  24.             db  44, 37, 36
  25.             db  27, 23, 23
  26.             db  58, 48, 46
  27.  
  28.             db  63, 29, 27
  29.             db  63, 37, 36
  30.             db  63, 23, 23
  31.             db  63, 48, 46
  32.  
  33. ────────────────────────────────────────────────────────────────────────────
  34. PROC LoadThePicture
  35.     pusha
  36.     push    ds
  37.     mov     ax,cs
  38.     mov     ds,ax
  39.  
  40.     mov     ah,0001b
  41.     @Set_Write_Plane
  42.  
  43.     mov     ax,3d00h
  44.     mov     dx,offset save1
  45.     int     21h
  46.     jc      @@NoFile
  47.     mov     bx,ax
  48.  
  49.     mov     ds,[cs:VGAseg]
  50.     xor     dx,dx
  51.     mov     cx,640/8*480
  52.     mov     ah,3fh
  53.     int     21h
  54.  
  55.     mov     ah,3eh
  56.     int     21h
  57.  
  58.     mov     ah,0010b
  59.     @Set_Write_Plane
  60.  
  61.     mov     ax,cs
  62.     mov     ds,ax
  63.     mov     ax,3d00h
  64.     mov     dx,offset save2
  65.     int     21h
  66.     jc      @@NoFile
  67.     mov     bx,ax
  68.  
  69.     mov     ds,[cs:VGAseg]
  70.     xor     dx,dx
  71.     mov     cx,640/8*480
  72.     mov     ah,3fh
  73.     int     21h
  74.  
  75.     mov     ah,3eh
  76.     int     21h
  77. @@NoFile:
  78.     pop     ds
  79.     popa
  80.     ret
  81. ENDP
  82. ────────────────────────────────────────────────────────────────────────────
  83. Include "sincos1k.dw"
  84. ANGLEMASK = 11111111110b
  85. ────────────────────────────────────────────────────────────────────────────
  86. LABEL Msg BYTE    
  87.     REPT 23
  88.         db  "This is a test.  "
  89.     ENDM
  90.         db  13,10,10,10
  91.         db  "            Hmmm... Does this look familiar to anyone???$"
  92. ────────────────────────────────────────────────────────────────────────────
  93. LABEL EndMask Byte
  94.     Rept 80
  95.         db  00000000b,10000000b,11000000b,11100000b
  96.         db  11110000b,11111000b,11111100b,11111110b
  97.     Endm
  98. LABEL FrontMask Byte
  99.     Rept 80
  100.         db  00000000b,00000001b,00000011b,00000111b
  101.         db  00001111b,00011111b,00111111b,01111111b
  102.     Endm
  103.  
  104. Angle   dw  0,10
  105. TmpXchg dd  0
  106. ────────────────────────────────────────────────────────────────────────────
  107.     ;bx hi = angle 1
  108.     ;bx lo = angle 2
  109. PROC DrawHLineMiddle
  110.     cld
  111.     mov     bp,40        ;line we are on
  112. @@BigLoop:
  113.     mov     di,bp
  114.     dec     di
  115.  
  116.     ror     ebx,16
  117.  
  118.     mov     si,bx
  119.     and     si,ANGLEMASK
  120.     mov     ax,[Sine + si]
  121.     add     ax,260
  122.     shr     ax,2
  123.     sub     bx,11
  124.  
  125.     ror     ebx,16
  126.  
  127.     add     bx,7
  128.     mov     si,bx
  129.     and     si,ANGLEMASK
  130.     add     ax,[Cosine + si]
  131.     mov     si,ax
  132.     add     si,260
  133.     shr     si,3
  134.     mov     cx,si
  135.     shr     cx,3            ;divide by 8
  136.     inc     cx
  137.     jcxz    @@SkipRep
  138.     sub     di,cx
  139.     dec     di
  140.     xor     al,al
  141.     stosb
  142. @@SkipRep:
  143.     mov     ah,11111111b
  144.     mov     al,[FrontMask + si]
  145.     stosw
  146.  
  147.     xchg    ebx,[TmpXchg]
  148.     ror     ebx,16
  149.     
  150.     mov     di,bp
  151.     inc     di
  152.     mov     si,bx
  153.     and     si,ANGLEMASK
  154.     mov     ax,[Sine + si]
  155.     add     ax,260
  156.     shr     ax,2
  157.     add     bx,7
  158.  
  159.     ror     ebx,16
  160.  
  161.     add     bx,3
  162.     mov     si,bx
  163.     and     si,ANGLEMASK
  164.     add     ax,[Cosine + si]
  165.     mov     si,ax
  166.     add     si,260
  167.     shr     si,3
  168.     mov     cx,si
  169.     shr     cx,3            ;divide by 8
  170.     jcxz    @@SkipRep2
  171.     add     di,cx
  172.     dec     di
  173.     mov     al,11111111b
  174.     stosb
  175. @@SkipRep2:
  176.     movzx   ax,[EndMask + si]
  177.     stosw
  178.  
  179.     xchg    ebx,[TmpXchg]
  180.  
  181.     add     bp,640/8
  182.     cmp     bp,640/8*480
  183.     jb      @@BigLoop
  184.  
  185.     ret
  186. ENDP
  187.  
  188. PROC DrawHLineRight
  189.  
  190.     cld
  191.     mov     bp,79        ;line we are on
  192. @@BigLoop:
  193.     mov     di,bp
  194.     dec     di
  195.  
  196.     ror     ebx,16
  197.  
  198.     mov     si,bx
  199.     and     si,ANGLEMASK
  200.     mov     ax,[Sine + si]
  201.     add     ax,260
  202.     shr     ax,2
  203.     add     bx,9
  204.     
  205.     ror     ebx,16
  206.     
  207.     sub     bx,4
  208.     mov     si,bx
  209.     and     si,ANGLEMASK
  210.     add     ax,[Cosine + si]
  211.     mov     si,ax
  212.     add     si,260
  213.     shr     si,2
  214.     mov     cx,si
  215.     shr     cx,3            ;divide by 8
  216.     inc     cx
  217.     jcxz    @@SkipRep
  218.     sub     di,cx
  219.     dec     di
  220.     xor     al,al
  221.     stosb
  222. @@SkipRep:
  223.     mov     ah,11111111b
  224.     mov     al,[FrontMask + si]
  225.     stosw
  226.  
  227.     add     bp,640/8
  228.     cmp     bp,640/8*480
  229.     jb      @@BigLoop
  230.  
  231.     ret
  232. ENDP
  233.  
  234. PROC DrawHLineLeft
  235.     cld
  236.     mov     bp,0        ;line we are on
  237. @@BigLoop:
  238.     mov     di,bp
  239.  
  240.     ror     ebx,16
  241.  
  242.     mov     si,bx
  243.     and     si,ANGLEMASK
  244.     mov     ax,[Sine + si]
  245.     add     ax,260
  246.     shr     ax,2
  247.     sub     bx,9
  248.  
  249.     ror     ebx,16
  250.     
  251.     add     bx,4
  252.     mov     si,bx
  253.     and     si,ANGLEMASK
  254.     add     ax,[Cosine + si]
  255.     mov     si,ax
  256.     add     si,260
  257.     shr     si,2
  258.     mov     cx,si
  259.     shr     cx,3            ;divide by 8
  260.     jcxz    @@SkipRep
  261.     add     di,cx
  262.     dec     di
  263.     mov     al,11111111b
  264.     stosb
  265. @@SkipRep:
  266.     movzx   ax,[EndMask + si]
  267.     stosw
  268.  
  269.     add     bp,640/8
  270.     cmp     bp,640/8*480
  271.     jb      @@BigLoop
  272.  
  273.     ret
  274. ENDP
  275.  
  276. PROC SetUp
  277.     xor     di,di
  278.     mov     cx,640/8*480/2
  279.     xor     ax,ax
  280.     cld
  281.     rep     stosw
  282.  
  283.     xor     di,di
  284.     xor     eax,eax
  285.     dec     eax
  286. @@TheLoop:
  287.     mov     [es:di],eax
  288.     mov     [es:di+36],eax
  289.     mov     [es:di+40],eax
  290.     mov     [es:di+76],eax
  291.     add     di,80
  292.     cmp     di,80*480
  293.     jb      @@TheLoop
  294.  
  295.     ret
  296. ENDP
  297.  
  298. PROC SetPalette
  299.     mov     bl,0
  300. @@PalLoop:
  301.     mov     dx,03dah
  302.     in      al,dx
  303.  
  304.     mov     dx,03c0h
  305.     mov     al,bl
  306.     out     dx,al
  307.     out     dx,al
  308.     inc     bl
  309.     cmp     bl,10h
  310.     jb      @@PalLoop
  311.  
  312.     mov     al,20h
  313.     out     dx,al
  314.     
  315.     mov     si,offset Palette
  316.     mov     cx,16*16
  317.     mov     al,0
  318.     @WritePalette
  319.     ret
  320. ENDP
  321. ────────────────────────────────────────────────────────────────────────────
  322.  
  323. Start:
  324.     mov     ax,cs
  325.     mov     ds,ax
  326.  
  327.     mov     ax,12h
  328.     int     10h
  329.  
  330.     mov     ah,9
  331.     mov     dx,offset Msg
  332.     int     21h
  333.  
  334.     call    SetPalette
  335.  
  336.     call    LoadThePicture
  337.  
  338.     mov     ax,cs
  339.     mov     ds,ax
  340.     mov     es,[VGAseg]
  341.     
  342.     mov     ah,1000b
  343.     @Set_Write_Plane
  344.  
  345.     call    Setup
  346.  
  347. @@MainLoop:
  348. ;    @WaitVert
  349.     @FullVertWait
  350.     mov     bx,[Angle+2]
  351.     shl     ebx,16
  352.     mov     bx,[angle]
  353.     call    DrawHLineLeft
  354.  
  355.     mov     bx,[Angle+2]
  356.     shl     ebx,16
  357.     mov     bx,[angle]
  358.     call    DrawHLineRight
  359.     
  360.     mov     bx,[Angle]
  361.     shl     ebx,16
  362.     mov     bx,[angle+2]
  363.     mov     [TmpXchg],ebx
  364.     mov     bx,[Angle+2]
  365.     shl     ebx,16
  366.     mov     bx,[angle]
  367.     call    DrawHLineMiddle
  368.  
  369.     add     [Angle],7
  370.     add     [Angle+2],17
  371.     
  372.     mov     ah,1
  373.     int     16h
  374.     jz      @@MainLoop
  375.  
  376.     mov     ah,0
  377.     int     16h
  378.     mov     ax,3
  379.     int     10h
  380.     mov     ah,4ch
  381.     int     21h
  382. ENd Start
  383.